﻿@model ArticleCategoryModel
@{
    Html.AddCssFileParts(true, "~/Content/assets/global/plugins/uniform/css/uniform.default.css");
}
@Html.HiddenFor(model => model.Id)
@Html.HiddenFor(model => model.ChannelId)
@Html.CafSite().TabStrip().Name("category-edit").Style(TabsStyle.Tabs).Position(TabsPosition.Top).Items(x =>
{
    x.Add().Text(T("Admin.ContentManagement.ArticleCategory.Info").Text).Icon("fa fa-pencil fa-lg fa-fw").Content(TabInfo()).Selected(true);
    x.Add().Text(T("Admin.Common.Extended").Text).Content(TabTemplate());
    x.Add().Text(T("Admin.Common.SpecificationAttributes").Text).Content(TabSpecificationAttributes()).Visible(true);
    x.Add().Text(T("Admin.Common.SEO").Text).Content(TabSeo());
    x.Add().Text(T("Admin.ContentManagement.ArticleCategory.Acl").Text).Content(TabAcl()).Visible(true);
    x.Add().Text(T("Admin.Common.Sites").Text).Content(TabSites()).Visible(Model.SiteContentShare);

    //generate an event
    EngineContext.Current.Resolve<IEventPublisher>().Publish(new TabStripCreated(x, "category-edit", this.Html, this.Model));
})

@helper TabInfo()
{
    <div class="row">
        <div class="col-md-4">
            <div class="form-body">
                <h2 class="margin-bottom-20">  @Html.ValidationSummary(true)</h2>

                <div id="divCategory" class="form-group">
                    <label class="control-label col-md-3">
                        @Html.LangLabelFor(model => model.ParentCategoryId)
                    </label>
                    <div class="col-md-9">
                        @* codehint: sm-edit *@
                        @(Html.HiddenFor(x => x.ParentCategoryId, new
                    {
                        style = "min-width: 200px",
                        @class = "form-control",
                        placeholder = "[" + T("Common.Unspecified") + "]",
                        data_select = true,
                        data_select_lazy = true,
                        data_select_init_text = Model.ParentCategoryBreadcrumb,
                        data_select_url = Url.Action("AllCategories", "ArticleCatalog", new { area = "", channelId = Model.ChannelId })
                    }))
                        @Html.ValidationMessageFor(model => model.ParentCategoryId)

                    </div>
                </div>
                @*<div class="form-group">
                            <label class="control-label col-md-3">
                                @Html.LangLabelFor(model => model.Alias)
                            </label>
                            <div class="col-md-9">
                                @Html.TextBoxFor(model => model.Alias, new { @class = "form-control" })
                                @Html.ValidationMessageFor(model => model.Alias)
                            </div>

                    @*<div class="form-group">
                            <label class="control-label col-md-3">
                                @Html.LangLabelFor(model => model.ChannelId)
                            </label>
                            <div class="col-md-3">
                                @Html.DropDownListFor(model => model.ChannelId, Model.Channels, new { @class = "form-control" })
                                @Html.ValidationMessageFor(model => model.ChannelId)

                            </div>
                        </div>*@


                <div class="form-group">
                    <label class="control-label col-md-3">
                        @Html.LangLabelFor(model => model.DisplayOrder) <span class="required" aria-required="true">*</span>
                    </label>
                    <div class="col-md-9">
                        @Html.EditorFor(model => model.DisplayOrder)
                        @Html.ValidationMessageFor(model => model.DisplayOrder)

                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">
                        @Html.LangLabelFor(model => model.PriceRanges)
                    </label>
                    <div class="col-md-9">
                        @Html.EditorFor(model => model.PriceRanges)
                        @Html.ValidationMessageFor(model => model.PriceRanges)

                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">
                        @Html.LangLabelFor(model => model.IconName)
                    </label>
                    <div class="col-md-9">
                        @Html.TextBoxFor(model => model.IconName, new { @class = "form-control" })
                        <span>Font-Awesome名称，带前缀fa</span>
                        @Html.ValidationMessageFor(model => model.IconName)

                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">
                        @Html.LangLabelFor(model => model.ShowOnHomePage)
                    </label>
                    <div class="col-md-9">
                        @Html.EditorFor(model => model.ShowOnHomePage)
                        @Html.ValidationMessageFor(model => model.ShowOnHomePage)

                    </div>
                </div>

                <div class="form-group">
                    <label class="control-label col-md-3">
                        @Html.LangLabelFor(model => model.Published)
                    </label>
                    <div class="col-md-9">
                        @Html.EditorFor(model => model.Published)
                        @Html.ValidationMessageFor(model => model.Published)

                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">
                        @Html.LangLabelFor(model => model.AllowUsersToSelectPageSize)
                    </label>
                    <div class="col-md-9">
                        @Html.EditorFor(model => model.AllowUsersToSelectPageSize)
                        @Html.ValidationMessageFor(model => model.AllowUsersToSelectPageSize)

                    </div>
                </div>
                <div class="form-group" id="pnlPageSize">
                    <label class="control-label col-md-3">
                        @Html.LangLabelFor(model => model.PageSize)
                    </label>
                    <div class="col-md-9">
                        @Html.EditorFor(model => model.PageSize)
                        @Html.ValidationMessageFor(model => model.PageSize)

                    </div>
                </div>
                <div class="form-group" id="pnlPageSizeOptions">
                    <label class="control-label col-md-3">
                        @Html.LangLabelFor(model => model.PageSizeOptions)
                    </label>
                    <div class="col-md-9">
                        @Html.TextBoxFor(model => model.PageSizeOptions, new { @class = "form-control" })
                        @Html.ValidationMessageFor(model => model.PageSizeOptions)

                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-3">
                        @Html.LangLabelFor(model => model.PictureId)
                    </label>
                    <div class="col-md-9">
                        @Html.EditorFor(model => model.PictureId, new { transientUpload = true })
                        @Html.ValidationMessageFor(model => model.PictureId)

                    </div>
                </div>

            </div>
        </div>
        <div class="col-md-8">

            @(Html.LocalizedEditor<ArticleCategoryModel, ArticleCategoryLocalizedModel>("category-info-localized",
            @<div class="form-body">
                <div class="form-group">
                    <label class="control-label col-md-2">
                        @Html.LangLabelFor(model => model.Locales[item].Name)
                    </label>
                    <div class="col-md-10">
                        @Html.TextBoxFor(model => Model.Locales[item].Name, new { @class = "form-control" })
                        @Html.ValidationMessageFor(model => model.Locales[item].Name)

                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">
                        @Html.LangLabelFor(model => model.Locales[item].FullName)
                    </label>
                    <div class="col-md-10">
                        @Html.TextBoxFor(model => Model.Locales[item].FullName, new { @class = "form-control" })
                        @Html.ValidationMessageFor(model => model.Locales[item].FullName)

                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">
                        @Html.LangLabelFor(model => model.Locales[item].Description)
                    </label>
                    <div class="col-md-10">
                        @Html.EditorFor(model => model.Locales[item].Description, Html.RichEditorFlavor())
                        @Html.ValidationMessageFor(model => model.Locales[item].Description)

                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">
                        @Html.LangLabelFor(model => model.Locales[item].BottomDescription)
                    </label>
                    <div class="col-md-10">
                        @Html.EditorFor(model => model.Locales[item].BottomDescription, Html.RichEditorFlavor())
                        @Html.ValidationMessageFor(model => model.Locales[item].BottomDescription)

                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">

                    </label>
                    <div class="col-md-10">
                        @Html.HiddenFor(model => model.Locales[item].LanguageId)
                    </div>
                </div>
            </div>
     ,
            @<div class="form-body">
                <div class="form-group">
                    <label class="control-label col-md-2">
                        @Html.LangLabelFor(model => model.Name)
                    </label>
                    <div class="col-md-10">
                        @Html.TextBoxFor(model => model.Name, new { @class = "form-control" })
                        @Html.ValidationMessageFor(model => model.Name)
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">
                        @Html.LangLabelFor(model => model.FullName)
                    </label>
                    <div class="col-md-10">
                        @Html.TextBoxFor(model => model.FullName, new { @class = "form-control" })
                        @Html.ValidationMessageFor(model => model.FullName)
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">
                        @Html.LangLabelFor(model => model.Description)
                    </label>
                    <div class="col-md-10">
                        @Html.EditorFor(x => x.Description, Html.RichEditorFlavor())
                        @Html.ValidationMessageFor(model => model.Description)
                    </div>
                </div>
                <div class="form-group">
                    <label class="control-label col-md-2">
                        @Html.LangLabelFor(model => model.BottomDescription)
                    </label>
                    <div class="col-md-10">
                        @Html.EditorFor(x => x.BottomDescription, Html.RichEditorFlavor())
                        @Html.ValidationMessageFor(model => model.BottomDescription)
                    </div>
                </div>
            </div>))
        </div>
    </div>

}

@helper TabTemplate()
{
    <div class="form-body">
        <div class="form-group">
            <label class="control-label col-md-3">
                @Html.LangLabelFor(model => model.ModelTemplateId)
            </label>
            <div class="col-md-3">
                @Html.DropDownListFor(model => model.ModelTemplateId, Model.AvailableModelTemplates, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.ModelTemplateId)
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-3">
                @Html.LangLabelFor(model => model.DetailModelTemplateId)
            </label>
            <div class="col-md-3">
                @Html.DropDownListFor(model => model.DetailModelTemplateId, Model.AvailableDetailModelTemplates, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.DetailModelTemplateId)
            </div>
        </div>

        <div class="form-group">
            <label class="control-label col-md-3">
                @Html.LangLabelFor(model => model.DefaultViewMode)
            </label>
            <div class="col-md-3">
                @Html.DropDownListFor(model => model.DefaultViewMode, Model.AvailableDefaultViewModes, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.DefaultViewMode)
            </div>
        </div>
    </div>
}

@helper TabSeo()
{
    @(Html.LocalizedEditor<ArticleCategoryModel, ArticleCategoryLocalizedModel>("category-seo-localized",
    @<div class="form-body">
        <div class="form-group">
            <label class="control-label col-md-2">
                @Html.LangLabelFor(model => model.Locales[item].MetaKeywords)
            </label>
            <div class="col-md-3">
                @Html.TextBoxFor(model => Model.Locales[item].MetaKeywords, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.Locales[item].MetaKeywords)

            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">
                @Html.LangLabelFor(model => model.Locales[item].MetaTitle)
            </label>
            <div class="col-md-6">
                @Html.TextBoxFor(model => Model.Locales[item].MetaTitle, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.Locales[item].MetaTitle)

            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">
                @Html.LangLabelFor(model => model.Locales[item].MetaDescription)
            </label>
            <div class="col-md-6">
                @Html.TextAreaFor(model => Model.Locales[item].MetaDescription, new { @class = "form-control", row = 5 })
                @Html.ValidationMessageFor(model => model.Locales[item].MetaDescription)

            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">
                @Html.LangLabelFor(model => model.Locales[item].SeName)
            </label>
            <div class="col-md-6">
                @Html.TextBoxFor(model => Model.Locales[item].SeName, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.Locales[item].SeName)

            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">

            </label>
            <div class="col-md-6">
                @Html.HiddenFor(model => model.Locales[item].LanguageId)
            </div>
        </div>
    </div>
     ,
    @<div class="form-body">
        <div class="form-group">
            <label class="control-label col-md-2">
                @Html.LangLabelFor(model => model.MetaKeywords)
            </label>
            <div class="col-md-6">
                @Html.TextBoxFor(model => model.MetaKeywords, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.MetaKeywords)
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">
                @Html.LangLabelFor(model => model.MetaTitle)
            </label>
            <div class="col-md-6">
                @Html.TextBoxFor(model => model.MetaTitle, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.MetaTitle)
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">
                @Html.LangLabelFor(model => model.MetaDescription)
            </label>
            <div class="col-md-6">
                @Html.TextAreaFor(model => model.MetaDescription, new { @class = "form-control", row = 5 })
                @Html.ValidationMessageFor(model => model.MetaDescription)
            </div>
        </div>
        <div class="form-group">
            <label class="control-label col-md-2">
                @Html.LangLabelFor(model => model.SeName)
            </label>
            <div class="col-md-6">
                @Html.TextBoxFor(model => model.SeName, new { @class = "form-control" })
                @Html.ValidationMessageFor(model => model.SeName)
            </div>
        </div>
    </div>))

}
@helper TabAcl()
{
    <script type="text/javascript">
        $(document).ready(function () {
            $('input[id="@Html.FieldIdFor(model => model.SubjectToAcl)"]').on('switchChange.bootstrapSwitch', function (event, state) {
                toggleAcl(state);
            });
            toggleAcl(@Model.SubjectToAcl.ToString().ToLower());
        });
        function toggleAcl(state) {
            if (state) {
                $('#pnl-acl').show();
            }
            else {
                $('#pnl-acl').hide();
            }
        }

    </script>
    <div class="form-group">
        <label class="control-label col-md-2">
            @Html.LangLabelFor(model => model.SubjectToAcl)
        </label>
        <div class="col-md-6">
            @Html.EditorFor(x => x.SubjectToAcl)
            @Html.ValidationMessageFor(model => model.SubjectToAcl)

        </div>
    </div>
    <div id="pnl-acl" class="form-group">
        <label class="control-label col-md-2">
            @Html.LangLabelFor(model => model.AvailableUserRoles)
        </label>
        <div class="col-md-6">
            @if (Model.AvailableUserRoles != null && Model.AvailableUserRoles.Count > 0)
            {
                foreach (var userRole in Model.AvailableUserRoles)
                {
                    <div>
                        <label class="checkbox">
                            <input type="checkbox" name="SelectedUserRoleIds" value="@userRole.Id" checked="@(Model.SelectedUserRoleIds != null && Model.SelectedUserRoleIds.Contains(userRole.Id))" />@userRole.Name
                        </label>
                    </div>
                }
            }
            else
            {
                <div>No user roles defined</div>
            }
        </div>
    </div>
}
@helper TabSites()
{
    <script type="text/javascript">
        $(document).ready(function () {
            $('input[id="@Html.FieldIdFor(model => model.LimitedToSites)"]').on('switchChange.bootstrapSwitch', function (event, state) {
                toggleSiteMapping(state);
            });
            toggleSiteMapping(@Model.LimitedToSites.ToString().ToLower());
        });
        function toggleSiteMapping(state) {
            if (state) {
                $('#pnl-available-sites').show();
            }
            else {
                $('#pnl-available-sites').hide();
            }
        }

    </script>

    <div class="form-group">
        <label class="control-label col-md-2">
            @Html.LangLabelFor(model => model.LimitedToSites)
        </label>
        <div class="col-md-6">
            @Html.EditorFor(x => x.LimitedToSites)
            @Html.ValidationMessageFor(model => model.LimitedToSites)

        </div>
    </div>
    <div id="pnl-available-sites" class="form-group">
        <label class="control-label col-md-2">
            @Html.LangLabelFor(model => model.AvailableSites)
        </label>
        <div class="col-md-6">
            @if (Model.AvailableSites != null && Model.AvailableSites.Count > 0)
            {
                foreach (var site in Model.AvailableSites)
                {
                    <label class="checkbox">
                        <input type="checkbox" name="SelectedSiteIds" value="@site.Id" checked="@(Model.SelectedSiteIds != null && Model.SelectedSiteIds.Contains(site.Id))" />
                        <span>@site.Name</span>
                    </label>
                }
            }
            else
            {
                <div>@T("Admin.Configuration.Sites.NoSitesDefined")</div>
            }
        </div>
    </div>

}
@helper TabSpecificationAttributes()
{
    <script type="text/javascript">
        $(function () {
            var count=@Model.ArticleCategorySpecificationAttributeModel.Count;
            if (count > 0)
            {
                getdata();
            }
            $("#@Html.FieldIdFor(model => model.AddSpecificationAttributeModel.SpecificationAttributeId)").change(function () {

                var selectedItem = $(this).val();
                var ddlSpecOptions = $("#@Html.FieldIdFor(model => model.AddSpecificationAttributeModel.SpecificationAttributeOptionId)")
                $.ajax({
                    cache: false,
                    type: "GET",
                    url: "@(Url.Action("GetOptionsByAttributeId", "SpecificationAttribute"))",
                    data: { "attributeId": selectedItem },
                    success: function (data) {
                        ddlSpecOptions.html('');
                        $.each(data, function (id, option) {
                            ddlSpecOptions.append($('<option></option>').val(option.id).html(option.name));
                        });
                        ddlSpecOptions.trigger("change");
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert('Failed to retrieve specification options.')
                    }
                });
            });
        });

        $(document).ready(function () {
            $('#addProductSpec').click(function () {
                var specificationAttributeId = $("#@Html.FieldIdFor(model => model.AddSpecificationAttributeModel.SpecificationAttributeId)").find(":selected").text();
                var specificationAttributeOptionId = $("#@Html.FieldIdFor(model => model.AddSpecificationAttributeModel.SpecificationAttributeOptionId)").val();
                var allowFiltering = $("#@Html.FieldIdFor(model => model.AddSpecificationAttributeModel.AllowFiltering)").is(':checked');
                var showOnProductPage = $("#@Html.FieldIdFor(model => model.AddSpecificationAttributeModel.ShowOnProductPage)").is(':checked');
                var displayOrder = $("#@Html.FieldIdFor(model => model.AddSpecificationAttributeModel.DisplayOrder)").val();
                var selectoption = $("#@Html.FieldIdFor(model => model.AddSpecificationAttributeModel.SpecificationAttributeOptionId)").html();
                $('#addProductSpec').attr('disabled', true);
                var num = new Date().valueOf();

                var html = ""

                html += '<tr id="tr' + num + '">'
                    + '<td class=""><span class="text-dep1"></span></td>'
                    + '<td><select style="width:260px" class="form-control spaoption-select">' + selectoption + '</select></td>'
                    + '<td class=""><input type="checkbox" value="' + allowFiltering + '"  class="check-box s_allowfiltering"/></td>'
                    + '<td class=""><input type="checkbox" value="' + showOnProductPage + '"  class="check-box s_showonarticlepage"/></td>'
                    + '<td class=""><input type="text"  value="' + displayOrder + '" class="form-control s_displayorder"></td>'
                    + '<td class=""><span class="pull-right"> <a href="javascript:;" class="text-info remove_fare">删除</a></span></td>'
                    + '</tr>'

                $("#addfare tbody").append(html);
                var trObj = $("#addfare tbody").find("#tr" + num + "");
                trObj.find(".text-dep1").html(specificationAttributeId);
                trObj.find("select.spaoption-select").val(specificationAttributeOptionId);
                trObj.find("input.s_allowfiltering").attr("checked", allowFiltering);
                trObj.find("input.s_showonarticlepage").attr("checked", showOnProductPage);

                $('#addProductSpec').attr('disabled', false);

                getdata();
            });

            //删除
            $(document).on('click', '.remove_fare', function (e) {
                $(this).parents("tr").remove();
                getdata();
            })


            //改变时修改数据
            $(document).on("change", "#addfare tbody tr input,#addfare tbody tr select", function () {
                getdata();
            })
        });


        //获取数据
        function getdata() {
            var trs = $("#addfare tbody tr");
            var trArr = [];
            $.each(trs, function (e) {
                var trObj = {};
                trObj.SpecificationAttributeOptionId = $(this).find("select.spaoption-select").val();
                trObj.AllowFiltering = $(this).find("input.s_allowfiltering").prop("checked")?"true":"false";
                trObj.ShowOnArticlePage = $(this).find("input.s_showonarticlepage").prop("checked")?"true":"false";
                trObj.DisplayOrder = $(this).find("input.s_displayorder").val();
                trArr.push(trObj);
            })
            $("input[name='SpaValues']").val(JSON.stringify(trArr));
        }
    </script>
    <div class="well">
        <div class="form-group">

            <div class="form-group">
                <label class="control-label col-md-2">
                    @Html.LangLabelFor(model => model.AddSpecificationAttributeModel.SpecificationAttributeId)
                </label>
                <div class="col-md-3">
                    @Html.DropDownListFor(model => model.AddSpecificationAttributeModel.SpecificationAttributeId, Model.AddSpecificationAttributeModel.AvailableAttributes, new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.AddSpecificationAttributeModel.SpecificationAttributeId)
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">
                    @Html.LangLabelFor(model => model.AddSpecificationAttributeModel.SpecificationAttributeOptionId)
                </label>
                <div class="col-md-3">
                    @Html.DropDownListFor(model => model.AddSpecificationAttributeModel.SpecificationAttributeOptionId, Model.AddSpecificationAttributeModel.AvailableOptions, new { @class = "form-control" })
                    @Html.ValidationMessageFor(model => model.AddSpecificationAttributeModel.SpecificationAttributeOptionId)
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">
                    @Html.LangLabelFor(model => model.AddSpecificationAttributeModel.AllowFiltering)
                </label>
                <div class="col-md-3">
                    @Html.EditorFor(model => model.AddSpecificationAttributeModel.AllowFiltering)
                    @Html.ValidationMessageFor(model => model.AddSpecificationAttributeModel.AllowFiltering)
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">
                    @Html.LangLabelFor(model => model.AddSpecificationAttributeModel.ShowOnProductPage)
                </label>
                <div class="col-md-3">
                    @Html.EditorFor(model => model.AddSpecificationAttributeModel.ShowOnProductPage)
                    @Html.ValidationMessageFor(model => model.AddSpecificationAttributeModel.ShowOnProductPage)
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">
                    @Html.LangLabelFor(model => model.AddSpecificationAttributeModel.DisplayOrder)
                </label>
                <div class="col-md-3">
                    @Html.EditorFor(model => model.AddSpecificationAttributeModel.DisplayOrder)
                    @Html.ValidationMessageFor(model => model.AddSpecificationAttributeModel.DisplayOrder)
                </div>
            </div>
            <div class="form-group">
                <label class="control-label col-md-2">
                </label>
                <div class="col-md-3">
                    <button type="button" name="addProductSpec" id="addProductSpec" class="btn btn-warning">
                        <i class="fa fa-plus"></i>
                        新增
                    </button>
                </div>
            </div>


        </div>
    </div>
    <div class="form-body">
        <div class="form-group">
            <label class="control-label col-md-2">
                <span class="help-block m-b-none text-muted"><i class="fa fa-info-circle text-info"></i>内容属性</span>
            </label>
            <div class="col-md-10">
                <input type="hidden" name="SpaValues" value="[]">
                <div class="row">
                    <div class="col-md-12 ">
                        <section class="panel panel-default">

                            <div class="table-responsive">
                                <table class="table  b-t b-light" id="addfare">
                                    <thead>
                                        <tr>
                                            <th style="width: 60px">属性</th>
                                            <th>属性值</th>
                                            <th class="" style="width: 120px">允许过滤</th>
                                            <th class="" style="width: 120px">在内容页面显示</th>
                                            <th class="" style="width: 120px">排序</th>
                                            <th class="" style="width: 120px">排序</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        @if (Model.ArticleCategorySpecificationAttributeModel.Count > 0)
                                        {

                                            foreach (var articleSpecificationAttributeModel in Model.ArticleCategorySpecificationAttributeModel)
                                            {
                                                var randNum = Guid.NewGuid().ToString();
                                                <tr id="tr@randNum">
                                                    <td class=""><span class="text-dep1">@articleSpecificationAttributeModel.SpecificationAttributeName</span></td>
                                                    <td>
                                                        <select style="width:260px" class="form-control spaoption-select">
                                                            @foreach (var specificationAttributeOption in articleSpecificationAttributeModel.SpecificationAttributeOptions)
                                                            {
                                                                <option @(specificationAttributeOption.select ? "selected" : "") value="@specificationAttributeOption.id">@specificationAttributeOption.name</option>
                                                            }
                                                        </select>
                                                    </td>
                                                    <td class=""><input type="checkbox" @(articleSpecificationAttributeModel.AllowFiltering ? "checked" : "") class="check-box s_allowfiltering"></td>
                                                    <td class=""><input type="checkbox" @(articleSpecificationAttributeModel.ShowOnArticlePage ? "checked" : "") class="check-box s_showonarticlepage"></td>
                                                    <td class=""><input type="text" value="@articleSpecificationAttributeModel.DisplayOrder" class="form-control s_displayorder"></td>
                                                    <td class=""><span class="pull-right"> <a href="javascript:;" class="text-info remove_fare">删除</a></span></td>
                                                </tr>
                                            }

                                        }
                                    </tbody>
                                </table>
                            </div>
                            <footer class="panel-footer"></footer>
                        </section>
                    </div>

                </div>

            </div>
        </div>
    </div>
}

<script type="text/javascript">
    $(document).ready(function () {
        $('input[id="@Html.FieldIdFor(model => model.AllowUsersToSelectPageSize)"]').on('switchChange.bootstrapSwitch', function (event, state) {
            togglePageSize(state);
        });
        togglePageSize(@Model.AllowUsersToSelectPageSize.ToString().ToLower());

        var CategoryIdSelect = $("#@Html.FieldIdFor(x => x.ParentCategoryId)");
        CategoryIdSelect.on("change", function (e) {
            if (e.val == '') return;
            var categoryid = e.val;
            loadParentCategory(categoryid)
        });
    });
    function togglePageSize(state) {
        if (state) {
            $('#pnlPageSize').hide();
            $('#pnlPageSizeOptions').show();
        }
        else {
            $('#pnlPageSize').show();
            $('#pnlPageSizeOptions').hide();
        }
    }

    function loadParentCategory(categoryid) {
        var url = '/admin/ArticleCategory/ParentArticleCategory/' + categoryid;
        $.ajax({
            cache: false,
            type: "GET",
            async: false,
            global: false,
            url: url,
            beforeSend: function (xhr) {

            },
            success: function (data, status, xhr) {
                $("#@Html.FieldIdFor(x => x.ModelTemplateId)").select2().val(data.ModelTemplateId).trigger("change");
                $("#@Html.FieldIdFor(x => x.DetailModelTemplateId)").select2().val(data.DetailModelTemplateId).trigger("change");
            },
            error: function (xhr, ajaxOptions, thrownError) {
                toastr['error'](thrownError, '@T("Admin.Common.Error").Text');
            },
            complete: function (xhr, status) {

            }
        });
    }
</script>
